package com.oa.controller;

import com.oa.pojo.Clock;
import com.oa.pojo.Party;
import com.oa.pojo.Result;
import com.oa.service.ClockService;
import com.oa.service.PartyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@ApiOperation(value = "打卡接口")
@RestController
@RequestMapping("/Clock")
public class ClockController {
    @Autowired
    private ClockService clockService;
    @CrossOrigin
    @GetMapping("/select")
    public Result selectByUserId(Clock clock){
        List<Clock> clockList=clockService.select(clock);
        return Result.success(clockList);
    }
    @ApiOperation(value="添加打卡信息")
    @CrossOrigin
    @PostMapping("/insert")
    public Result insert(@RequestBody Clock clock){
        System.out.println("进入添加打卡信息接口");
        if(clockService.insert(clock)==1){
            return Result.success();
        }else{
            return Result.error("该信息已存在");
        }
    }
    @ApiOperation(value = "更新打卡信息")
    @CrossOrigin
    @PostMapping("/update")
    public Result update(@RequestBody Clock clock){
        System.out.println("进入打卡信息更新接口");
        int flag= clockService.update(clock);
        if(flag==1){
            return Result.success();
        }else{
            return Result.error("该信息不存在");
        }
    }
    @ApiOperation(value = "打卡信息删除接口")
    @CrossOrigin
    @PostMapping("/delete")
    public Result delete(Clock clock){
        System.out.println("进入党员删除接口");
        int flag=clockService.delete(clock);
        if(flag==1){
            return Result.success();
        }else{
            return Result.error("该信息不存在");
        }
    }
}
